package com.cse.bpass;

import java.io.File;
import java.util.Locale;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Vibrator;
import android.speech.tts.TextToSpeech;
import android.view.Display;
import android.view.KeyEvent;
import android.view.WindowManager;

public class Setting extends Activity implements TextToSpeech.OnInitListener{
	protected static TextToSpeech tts;	

	
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
        setContentView(R.layout.setting);

        
        //Create TextToSpeech
        tts = new TextToSpeech(this,this);
        tts.setLanguage(Locale.US);
        
        Display dis = ((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
		int width = dis.getWidth();
		int height = dis.getHeight();
		Vibrator vibrator= (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
		
		if(new File("/sdcard/password.txt").exists()){
			PasscodeView sv = new PasscodeView(this, width, height, 2, vibrator, tts);
			setContentView(sv);
		}else{
			PasscodeView sv = new PasscodeView(this, width, height, 0, vibrator, tts);
			setContentView(sv);
		}
	}
	
	@Override
	public void onAttachedToWindow(){
		super.onAttachedToWindow();
		this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
	}
	
    @Override
    public void onDestroy() {
        // Don't forget to shutdown!
        if (tts != null) {
           tts.stop();
            tts.shutdown();
        }

        super.onDestroy();
    }
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if(keyCode == KeyEvent.KEYCODE_HOME){
		}
		
		if(keyCode == KeyEvent.KEYCODE_BACK){
		}
		
		if(keyCode == KeyEvent.KEYCODE_MENU){
		}
		
		if(keyCode == KeyEvent.KEYCODE_SEARCH){
		}
		
		if(keyCode == KeyEvent.KEYCODE_CAMERA){
		}

		return false;
	}

	public void onInit(int status) {
		tts.speak("Setting button clicked", TextToSpeech.QUEUE_ADD, null);
	}
}
